R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

## 
##    *****       ***   vcfR   ***       *****
##    This is vcfR 1.10.0 
##      browseVignettes('vcfR') # Documentation
##      citation('vcfR') # Citation
##    *****       *****      *****       *****
## Loading required package: ade4
## Registered S3 method overwritten by 'spdep':
##   method   from
##   plot.mst ape
## 
##    /// adegenet 2.1.2 is loaded ////////////
## 
##    > overview: '?adegenet'
##    > tutorials/doc/questions: 'adegenetWeb()' 
##    > bug reports/feature requests: adegenetIssues()
## Registered S3 methods overwritten by 'adegraphics':
##   method         from
##   biplot.dudi    ade4
##   kplot.foucart  ade4
##   kplot.mcoa     ade4
##   kplot.mfa      ade4
##   kplot.pta      ade4
##   kplot.sepan    ade4
##   kplot.statis   ade4
##   scatter.coa    ade4
##   scatter.dudi   ade4
##   scatter.nipals ade4
##   scatter.pco    ade4
##   score.acm      ade4
##   score.mix      ade4
##   score.pca      ade4
##   screeplot.dudi ade4
## 
## Attaching package: 'adegraphics'
## The following objects are masked from 'package:ade4':
## 
##     kplotsepan.coa, s.arrow, s.class, s.corcircle, s.distri, s.image,
##     s.label, s.logo, s.match, s.traject, s.value, table.value,
##     triangle.class
## Loading required package: ape
## 
## Attaching package: 'ape'
## The following object is masked from 'package:adegraphics':
## 
##     zoom
## Registered S3 method overwritten by 'pegas':
##   method      from
##   print.amova ade4
## 
## Attaching package: 'pegas'
## The following object is masked from 'package:ape':
## 
##     mst
## The following object is masked from 'package:ade4':
## 
##     amova
## The following object is masked from 'package:vcfR':
## 
##     getINFO
## Warning: package 'lattice' was built under R version 3.6.2
## 
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
## 
##     lowess
## Loading required package: ggplot2
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
## Warning: package 'reshape2' was built under R version 3.6.2
## Warning: package 'karyoploteR' was built under R version 3.6.1
## Loading required package: regioneR
## Warning: package 'regioneR' was built under R version 3.6.1
## Loading required package: GenomicRanges
## Warning: package 'GenomicRanges' was built under R version 3.6.1
## Loading required package: stats4
## Loading required package: BiocGenerics
## Loading required package: parallel
## 
## Attaching package: 'BiocGenerics'
## The following objects are masked from 'package:parallel':
## 
##     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
##     clusterExport, clusterMap, parApply, parCapply, parLapply,
##     parLapplyLB, parRapply, parSapply, parSapplyLB
## The following object is masked from 'package:adegraphics':
## 
##     score
## The following object is masked from 'package:ade4':
## 
##     score
## The following objects are masked from 'package:stats':
## 
##     IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
## 
##     anyDuplicated, append, as.data.frame, basename, cbind, colnames,
##     dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep,
##     grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget,
##     order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
##     rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
##     union, unique, unsplit, which, which.max, which.min
## Loading required package: S4Vectors
## Warning: package 'S4Vectors' was built under R version 3.6.1
## 
## Attaching package: 'S4Vectors'
## The following object is masked from 'package:gplots':
## 
##     space
## The following object is masked from 'package:base':
## 
##     expand.grid
## Loading required package: IRanges
## Warning: package 'IRanges' was built under R version 3.6.1
## Loading required package: GenomeInfoDb

VCF Analysis using vcfR

Fisher Test for Mutation Rate

Bedgraph Plots for Coverage - Old Style

# if (!requireNamespace("BiocManager", quietly = TRUE))
#     install.packages("BiocManager")
# 
# BiocManager::install("karyoploteR")


# browseVignettes("karyoploteR")
#Function from Sam 
# make_karyo_Spar337 <- function(mergefile,title) {
  Chr_sizes_GR <- toGRanges("~/Dropbox/McQueary/Paradoxus_MA/Ref_Genome/337_chrm_sizes_red.bed") ## This is just a three column bed file of the chromosome sizes
  gene_bed_GR <- toGRanges("/Users/hollymcqueary/Dropbox/McQueary/Paradoxus_MA/Ref_Genome/337_sites_2.bed") ## This is just a three column bed file of the gene positions (just the gene entries from the gff3 file)
  # supergene_GR <- GRanges(seqnames = "lg16",ranges=IRanges(7311525,18123987)) ## I made this GRanges object to delineate the supergene to add a block for it later

chroms <- c("Spar_I_RaGOO", "Spar_II_RaGOO", "Spar_III_RaGOO", "Spar_IV_RaGOO", "Spar_V_RaGOO", "Spar_VI_RaGOO", "Spar_VII_RaGOO", "Spar_VIII_RaGOO", "Spar_IX_RaGOO", "Spar_X_RaGOO", "Spar_XI_RaGOO", "Spar_XII_RaGOO", "Spar_XIII_RaGOO", "Spar_XIV_RaGOO", "Spar_XV_RaGOO","Spar_XVI_RaGOO")
  # kp <- plotKaryotype(genome=Chr_sizes_GR)  
  # plot.params <- getDefaultPlotParams(plot.type = 1) ## This defines how the plot will generally be structured. See the options in the karyoploter documentation
  # plot.params$data1height=8
  # plot.params$data1outmargin = 4
  # plot.params$data1inmargin = 2
  # plot.params$ideogramheight = 2

# D20_A_cov <- read.table("/Users/hollymcqueary/Dropbox/McQueary/Paradoxus_MA/BedGraphs/D20/D20-A_.bedgraph")
# str(D20_A_cov)
# colnames(D20_A_cov) <- c("chr","start","end","coverage")
# D20_A_GR <- makeGRangesFromDataFrame(D20_A_cov,seqnames.field = "chr", start.field = "start", end.field = "end", keep.extra.columns = TRUE)
#   # ordered <- D20_A_GR[order(D20_A_GR$coverage, na.last = TRUE),] ## Sorts my DEG data to plot the top ten most DE genes later
#   fc.ymax=ceiling(max(abs(D20_A_GR$coverage))) ## Define the maximum axes of the DEG plots
#   fc.ymin=0 ## Define the minimum axes of the DEG plots 
# TEs <- read.table("/Users/hollymcqueary/Dropbox/McQueary/Paradoxus_MA/BedGraphs/TELocate/D20/raw/D20-A-R_R1_val_telocate_raw.TY1.bed")
# colnames(TEs) <- c("chr","start","end","TE")
# str(TEs)  
# TEs.2 <- toGRanges(TEs)
# TEs.3 <- toDataframe(TEs.2)


# kpPlotRegions(kp1,data=TEs.2,col="#AACCFF",later.margin=0.01,border=NA,r0=0,r1=0.5)

## Place the DE dots in the region of the plot that I want
  # kpAxis(kp, ymax=fc.ymax, ymin=fc.ymin,side = 2,cex=0.5,r0 = 0.15, r1 = 0.7) ## Add the axis for the DE dots
  # kpAddMainTitle(kp,main=title) ## Add a title to the plot
  # kpPlotRegions(kp,data = supergene_GR,col="red", r0=0,r1=0.1) ## add a box to show where the supergene is
  # kpPlotMarkers(kp, ordered[1:10], labels = ordered[1:10]$Row.names, text.orientation = "vertical",adjust.label.position = TRUE,r0 = 0.75) ## Add markers for the top 10 most DE genes
  # 

## Load in, filter and format the DE data to be plotted. End result should be a GRanges object with extra columns of differential expression stats (logFC, FDR, etc)
  # temp <- mergefile
  # temp$chr <- as.character(temp$chr)
  # temp.sig<-temp[(temp$FDR<=0.01 & grepl("lg",temp$chr)),]
  # temp.sig <- temp.sig[complete.cases(temp.sig), ]
  # DEG_GR <- makeGRangesFromDataFrame(temp.sig, seqnames.field = "chr",start.field = "start",end.field = "end",keep.extra.columns = TRUE)
  # 
  ## Begin generating the plot itself. If you want to change anything in the plot after first generating it, start again here. 
  # kp <- plotKaryotype(genome = Chr_sizes_GR, cytobands = gene_bed_GR,chromosomes = c("Spar_XVI_RaGOO"),plot.params = plot.params)
  # ordered <- DEG_GR[order(DEG_GR$FDR, na.last = TRUE),] ## Sorts my DEG data to plot the top ten most DE genes later
  # fc.ymax=ceiling(max(abs(DEG_GR$logFC))) ## Define the maximum axes of the DEG plots
  # fc.ymin=0 ## Define the minimum axes of the DEG plots 
  # cex.val <- -log10(DEG_GR$FDR)/7 ## Sets the size for each gene dot based on significance
  # col.over <- "#FFBD07AA" #Yellow
  # col.under <- "#00A6EDAA" #Blue
  # col.insig <- "#7F7F7F"
  # sign.col <- rep(col.insig, length(DEG_GR)) ## This and the next two lines generate a an array of color entries linked to the genes to color the dots
  # sign.col[(DEG_GR$logFC<0)&(DEG_GR$FDR<=0.01)] <- col.under
  # sign.col[(DEG_GR$logFC>0)&(DEG_GR$FDR<=0.01)] <- col.over
  
  # kpPoints(kp, data=DEG_GR, y=abs(DEG_GR$logFC), ymax=fc.ymax, ymin=fc.ymin,cex=cex.val, col=sign.col,r0 = 0.15, r1 = 0.7) ## Place the DE dots in the region of the plot that I want
  # kpAxis(kp, ymax=fc.ymax, ymin=fc.ymin,side = 2,cex=0.5,r0 = 0.15, r1 = 0.7) ## Add the axis for the DE dots
  # kpAddMainTitle(kp,main=title) ## Add a title to the plot
  # kpPlotRegions(kp,data = supergene_GR,col="red", r0=0,r1=0.1) ## add a box to show where the supergene is
  # kpPlotMarkers(kp, ordered[1:10], labels = ordered[1:10]$Row.names, text.orientation = "vertical",adjust.label.position = TRUE,r0 = 0.75) ## Add markers for the top 10 most DE genes
  
# } ## Make karyoplot for linearized genome (!!)


# ##################################################################################################
# ##################################################################################################
# # library(Sushi)
# 
# # data(list=c("Sushi_DNaseI.bedgraph","Sushi_ChIPSeq_CTCF.bedgraph",
#         # "Sushi_ChIPExo_CTCF.bedgraph"), package="Sushi")
# 
# D20 = read.table("/Users/hollymcqueary/Dropbox/McQueary/Paradoxus_MA/BedGraphs/D20/D20-A_.bedgraph")
# D20_TE = read.table("/Users/hollymcqueary/Dropbox/McQueary/Paradoxus_MA/BedGraphs/TELocate/D20/raw/D20-A-R_R1_val_telocate_raw.TY1.bed")
# 
# dd <- list(D20=D20_A_cov)#, D20_TE=D20_TE)
# 
# png("bedgraphPlot.png", width = 1500, height = 1000)
#   kp <- plotKaryotype(zoom="chr1:1-240865",main = "BedGraphs", cex=1)
#   kpAddBaseNumbers(kp, tick.dist = 10e4, add.units = TRUE, cex=0.5)
#   for(i in seq_len(length(dd))) {
#     names(dd[[i]]) <- c("chr", "start", "end", "value") 
#     gr <- toGRanges(dd[[i]])
#     # at <- autotrack(i, length(dd), margin = 0.1)
#     kpPoints(kp, data=gr, ymax=max(gr$value), col=rainbow(10)[i])
#     kpAddLabels(kp, labels = names(dd)[i], cex=0.5)
#   }
# dev.off()
# 
# str(D20)
# 
#     names(D20) <- c("chr", "start", "end", "value") 
#     gr <- toGRanges(D20)
#     # at <- autotrack(D20, length(D20), margin = 0.1)
#     kp <- plotKaryotype(main = "BedGraphs", cex=3)
#     kpAddBaseNumbers(kp, tick.dist = 10e4, add.units = TRUE, cex=1.8)
#     kpPoints(kp, data=gr, ymax=max(gr$value),col=rainbow(10)D20)
#     kpAddLabels(kp, labels = names(D20), r0=at$r0, r1=at$r1)



############## This script works for me ###############
###################################################
### Call karyotype plot 
## Specify which chromosome in this
# load in chromosome sizes and cytobands files


# {kp1 <- plotKaryotype(plot.type=2, genome=Chr_sizes_GR,cytobands=gene_bed_GR,chromosomes = c("Spar_XII_RaGOO"))
# # this tells the program to add base numbers (self-explanatory)
# kpAddBaseNumbers(kp1)
# # this plots whatever markers you tell it to - in this case, markers of TEs in this genome
# kpPlotMarkers(kp1, chr=TEs$chr, x=TEs$start, labels=TEs$TE,data.panel=2)
# # this plots the coverage in 10kb chunks bc that's what we computed
# kpBars(kp1, data=D20_A_GR, y1=D20_A_GR$coverage, ymax=max(D20_A_GR$coverage)/2, data.panel=1,col="blue")}
# # gives a plot of chromosome XII with coverage on top and TE locations on the bottom 


## check out D20-1, look at chr VI first, then chr XVI


# D20_1_cov <- read.table("/Users/hollymcqueary/Dropbox/McQueary/Paradoxus_MA/BedGraphs/D20/HM-D20-1.bedgraph")
# str(D20_1_cov)
# colnames(D20_1_cov) <- c("chr","start","end","coverage")
# D20_1_GR <- makeGRangesFromDataFrame(D20_1_cov,seqnames.field = "chr", start.field = "start", end.field = "end", keep.extra.columns = TRUE)
# TEs_1 <- read.table("/Users/hollymcqueary/Dropbox/McQueary/Paradoxus_MA/BedGraphs/TELocate/D20/raw/HM-D20-1_R1_001_val_telocate.bed")
# colnames(TEs_1) <- c("chr","start","end","TE")
# str(TEs_1)  
# TEs_1 <- toGRanges(TEs_1)
# TEs.3 <- toDataframe(TEs.2)

# {kp1 <- plotKaryotype(plot.type=2, genome=Chr_sizes_GR,cytobands=gene_bed_GR,chromosomes = c("Spar_XII_RaGOO"))
# # this tells the program to add base numbers (self-explanatory)
# kpAddBaseNumbers(kp1)
# # this plots whatever markers you tell it to - in this case, markers of TEs in this genome
# kpPlotMarkers(kp1, data=TEs_1, chr=TEs_1$chr, x=TEs_1$start, labels=TEs_1$TE, data.panel=2)
# # this plots the coverage in 10kb chunks bc that's what we computed
# kpBars(kp1, data=D20_1_GR, y1=D20_1_GR$coverage, ymax=max(D20_1_GR$coverage)/2, data.panel=1,col="green", r0=0, r1=0.25)
# }
# # gives a plot of chromosome XII with coverage on top and TE locations on the bottom 
# kpBars(kp1, data=D20_A_GR, y1=D20_A_GR$coverage, ymax=max(D20_A_GR$coverage)/2, data.panel = 1, col="blue",r0=0.25, r1=0.5)
# kpPlotCoverage(kp1, data=D20_A_GR, data.panel = 1, col="blue",r0=0.25, r1=0.5)
# You need to make sure that the chromosome you call in plotKaryotype is present in the TE file and that the chromosome names match (i.e. the TE files don't have _RaGOO at the end of their chromosome names)

####################################################################################################################
#### Trying with .depth file generated by Audrey (this file has depth at every site in the genome )

# D20_10_depth <- read.table("/Users/hollymcqueary/Dropbox/McQueary/Paradoxus_MA/BedGraphs/D20/HM-D20-10.depth")
# str(D20_10_depth)
# colnames(D20_10_depth) <- c("chr","pos","coverage")
# D20_10_GR <- makeGRangesFromDataFrame(D20_10_depth,seqnames.field = "chr", start.field = "pos", end.field = "pos", keep.extra.columns = TRUE)
# 
# TEs_10 <- read.table("/Users/hollymcqueary/Dropbox/McQueary/Paradoxus_MA/BedGraphs/TELocate/D20/raw/HM-D20-10_R1_001_val_telocate_raw.TY1.bed")
# colnames(TEs_10) <- c("chr","start","end","TE")
# str(TEs_10)  
# TEs_10 <- toGRanges(TEs_10)
# TEs.3 <- toDataframe(TEs.2)

# mid.regs <- createRandomRegions(nregions = 6000, length.mean = 5000000, length.sd = 1000000, non.overlapping = FALSE)


plotDepthTELocations <- function(depthFile,teFile,sample,chroms) {
  # load in depth table 
  depth <- read.table(depthFile)
  #add column names
colnames(depth) <- c("chr","pos","coverage")
# turn file into a GRanges object
depthGR <- makeGRangesFromDataFrame(depth,seqnames.field = "chr", start.field = "pos", end.field = "pos", keep.extra.columns = TRUE)
# load in TE file (from TELocate)
TEs <- teFile
# add column names 
colnames(TEs) <- c("chr","start","end","TE")
# make GRanges object from TE file 
TEs <- toGRanges(TEs)
# make pdf plot for all chromosomes: depth + TE locations 

# {pdf(paste("depthTELocate",sample,chroms,".pdf",sep=""))
  #general plotKaryotype command (same for all samples)
  kp <- plotKaryotype(genome=Chr_sizes_GR, cytobands=gene_bed_GR, chromosomes= chroms, cex=0.5, main = paste(sample,chroms,sep="_"))
# this tells the program to add base numbers (self-explanatory)
  # can specify how spaced out you want them using tick.dist 
  # units adds "kb", "mb", etc 
kpAddBaseNumbers(kp,tick.dist = 100000,add.units = TRUE)
# this plots whatever markers you tell it to - in this case, markers of TEs in this genome
# can specify colors of lines and text, distance labels are from each other, etc 
# data panel = 2 specifies that it is the bottom panel 
kpPlotMarkers(kp, data=TEs, chr=TEs$chr, x=TEs$start, labels=TEs$TE, data.panel=2,cex=0.5, text.orientation = "horizontal", line.color = "pink", label.color = "purple", label.dist = 0.01, max.iter = 1000)
# this plots coverage at every base along each chromosome from depth file 
# data panel = 1 specifies it is the top panel 
kpBars(kp, data=depthGR, y1=depthGR$coverage, ymax=max(depthGR$coverage)/2, data.panel=1)
# dev.off() }

}

depthFileNamesD20 <- list.files(path = "/Users/hollymcqueary/Dropbox/depthFiles/D20", pattern="*.depth",full.names = TRUE)

testDepth <- read.table("/Users/hollymcqueary/Dropbox/depthFiles/D20/HM-D20-24.depth")
consensusTEs <- read.table("/Users/hollymcqueary/Dropbox/McQueary/Paradoxus_MA/BedGraphs/TELocate/consensusTEs.txt")
# plotDepthTELocations(testDepth,consensusTEs,"Sample24All","Spar_II_RaGOO")
# plotDepthTELocations(testDepth,consensusTEs,"Sample24All",chroms)

# i=1
sampleNames <- c("Sample1","Sample10","Sample11","Sample12","Sample13","Sample14","Sample15","Sample16","Sample17","Sample18","Sample19","Sample2","Sample20","Sample21","Sample22","Sample23","Sample24","Sample25","Sample26","Sample27","Sample28","Sample29","Sample3","Sample30","Sample31","Sample32","Sample33","Sample34","Sample35","Sample36","Sample37","Sample38","Sample39","Sample4","Sample40","Sample41","Sample42","Sample43","Sample44","Sample45","Sample46","Sample47","Sample48","Sample5","Sample6","Sample8","Sample9","Ancestor")
sampleNames[12]
## [1] "Sample2"
length(sampleNames)
## [1] 48
length(depthFileNamesD20)
## [1] 48
plotDepthTELocations(depthFileNamesD20[17],consensusTEs,sampleNames[17],"Spar_II_RaGOO")
## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands.
## Using 'gpos50' (gray) for all of them

plotDepthTELocations(depthFileNamesD20[3],consensusTEs,sampleNames[3],"Spar_X_RaGOO")
## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands.
## Using 'gpos50' (gray) for all of them

plotDepthTELocations(depthFileNamesD20[17],consensusTEs,sampleNames[17],"Spar_IX_RaGOO")
## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands.
## Using 'gpos50' (gray) for all of them

plotDepthTELocations(depthFileNamesD20[3],consensusTEs,sampleNames[3],"Spar_XIV_RaGOO")
## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands.
## Using 'gpos50' (gray) for all of them

plotDepthTELocations(depthFileNamesD20[12],consensusTEs,sampleNames[12],"Spar_XIV_RaGOO")
## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands.
## Using 'gpos50' (gray) for all of them

plotDepthTELocations(depthFileNamesD20[13],consensusTEs,sampleNames[13],"Spar_XV_RaGOO")
## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands.
## Using 'gpos50' (gray) for all of them

for(i in 1:48) {
plotDepthTELocations(depthFileNamesD20[i],consensusTEs,sampleNames[i],"Spar_VI_RaGOO")
}
## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands.
## Using 'gpos50' (gray) for all of them
## Warning in .Seqinfo.mergexy(x, y): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

## Warning in ideogram.plotter(kp, ...): No 'gieStain' column found in cytobands. Using 'gpos50' (gray) for all of them

## Warning in ideogram.plotter(kp, ...): The 2 combined objects have no sequence levels in common. (Use
##   suppressWarnings() to suppress this warning.)

#, r0=0, r1=0.25)}
# kpBars(kp1, data=D20_A_GR, y1=D20_A_GR$coverage, ymax=max(D20_A_GR$coverage)/2, data.panel = 1, col="blue",r0=0.25, r1=0.5)
# kpPlotCoverage(kp1, data=D20_10_GR, data.panel = 1, col="blue",r0=0.25, r1=0.5)}
# gives a plot of chromosome XII with coverage on top and TE locations on the bottom 

# You need to make sure that the chromosome you call in plotKaryotype is present in the TE file and that the chromosome names match (i.e. the TE files don't have _RaGOO at the end of their chromosome names)
# kpPlotRegions(kp10, data=gene_bed_GR,data.panel = 2)
##### Use kpRect to plot TEs so you can use start and stop positions to show length of TE 
# kpPlotRegions(kp10, data=TEs_10, border=NA, r0=0.2, r1=1, data.panel = 2)

Packages used in this analysis

library(vcfR)
library(adegenet)
library(adegraphics)
library(pegas)
library(StAMPP)
library(lattice)
library(gplots)
library(ape)
library(ggmap)
library(pinfsc50)
library(reshape2)
library(ggplot2)
library(karyoploteR)
library(GenomicRanges)